<template>
  <div>
    <el-form ref="queryForm" :model="queryForm" :inline="true" size="mini">
      <!-- 顾客名称 -->
      <el-form-item label="顾客名称" prop="customerName">
        <el-select
          v-model="queryForm.customerName"
          filterable
          placeholder="请输入顾客名称"
          allow-create
          default-first-option
          clearable
          style="width: 10vw"
        >
          <el-option
            v-for="item in customerList"
            :key="item.id"
            :label="item.customerName"
            :value="item.customerName"
          >
          </el-option>
        </el-select>
      </el-form-item>

      <!-- 钢类 -->
      <el-form-item label="钢类" prop="steelTypeId">
        <el-select v-model="queryForm.steelTypeId" placeholder="请选择钢类" style="width: 8vw">
          <el-option v-for="item in steelTypes" :key="item.id" :value="item.steelTypeName" :label="item.steelTypeName" />
        </el-select>
      </el-form-item>

      <!-- 钢种 -->
      <el-form-item label="钢种" prop="steelGradeId">
        <el-select v-model="queryForm.steelGradeId" placeholder="请选择钢种" style="width: 8vw" filterable
        allow-create
        default-first-option
        clearable>
          <el-option v-for="item in steelGradeList" :key="item.id" :value="item.steelGradeName"
            :label="item.steelGradeName" />
        </el-select>
      </el-form-item>

      <!-- 修改日期 -->
      <el-form-item label="修改日期" prop="submitTime">
        <el-date-picker v-model="queryForm.submitTime" value-format="yyyy-MM-dd" type="date" placeholder="选择日期"
          style="width: 8vw">
        </el-date-picker>
      </el-form-item>
      <!-- 编号 -->
      <el-form-item label="编号" prop="code">
        <el-input v-model="queryForm.code" placeholder="请输入编号" style="width: 8vw"></el-input>
      </el-form-item>
      <!-- 查询和重置按钮 -->
      <el-form-item>
        <el-button type="primary" size="small" @click="getReviewedOrder()">查询</el-button>
        <el-button type="success" size="small"
          @click="() => { $refs.queryForm.resetFields(); handleCurrentChange(1) }">重置</el-button>
      </el-form-item>
    </el-form>
    <el-card style="height:100%">
      <div slot="header">
        <span>修改评审意见订单记录</span>
      </div>
      <hmi-table :table-data="tableData" :is-pagination-show="true" :table-height="'calc(100vh - 230px)'"
        :table-head="true" :total="total" :current-page="queryForm.current" :page-size="queryForm.page"
        index-tyle="index" @handle-size-change="handleSizeChange" @handle-current-change="handleCurrentChange">
        <template slot="TableBody">
          <!-- 序号 -->
          <el-table-column label="序号" width="60" align="center" type="index" />

          <!-- 编号 -->
          <el-table-column prop="code" label="编号" align="center" />

          <!-- 顾客名称 -->
          <el-table-column prop="customerName" width="160" label="顾客名称" align="center" />

          <!-- 顾客联系方式 -->
          <el-table-column prop="customerPhone" width="160" label="顾客联系方式" align="center" />

          <!-- 钢类 -->
          <el-table-column prop="steelTypeName" label="钢类" align="center"></el-table-column>
          <!-- 钢种 -->
          <el-table-column prop="steelGradeName" label="钢种" align="center" show-overflow-tooltip></el-table-column>
          <!-- 标准 -->
          <el-table-column prop="standardName" label="标准" align="center" show-overflow-tooltip/>

          <!-- 规格 -->
          <el-table-column prop="specification" label="规格" align="center" />

          <!-- 数量 -->
          <el-table-column prop="steelNumber" label="数量" align="center">
            <template slot-scope="scope">
              {{ scope.row.steelNumber }}{{ scope.row.steelNumberUnit }}
            </template>
          </el-table-column>

          <!-- 交货状态 -->
          <el-table-column prop="deliveryStatus" label="交货状态" align="center" />

          <!-- 技术评审部门 -->
          <el-table-column prop="department" label="技术评审部门" align="center" />

          <!-- 修改用户 -->
          <el-table-column prop="modifiedUser" label="修改用户" align="center" />

          <!-- 修改评审意见时间 -->
          <el-table-column prop="auditTime" label="修改评审意见时间" width="150" align="center">
            <template slot-scope="scope">
              <span>{{ formatterTime(scope.row.auditTime) }}</span>
            </template>
          </el-table-column>

          <!-- 修改内容(查看) -->
          <el-table-column label="操作" width="70" align="center">
            <template slot-scope="scope">
              <el-button type="text" @click="handleViewContent(scope.row)">查看</el-button>
            </template>
          </el-table-column>
        </template>
      </hmi-table>
    </el-card>
  </div>
</template>

<script>
import PageTitle from "@/components/PageTitle";
import { timeChange } from "@/lib/FormatTime";
import {
  GET_STANDARD_OPINIONRECORD,
  GET_STEELGRADELIST,
  GET_STEELTYPELIST,
  GET_CUSTOMERNAMELIST
} from "@/lib/Api.js";
import { post } from "@/lib/Util.js";
import HmiTable from "@/components/HmiTable";
export default {
  components: {
    PageTitle,
    HmiTable
  },
  data() {
    return {
      queryForm: {
        auditTime: "",
        code: "",
        current: 1,
        customerName: "",
        page: 5,
        steelGradeId: "",
        steelTypeId: "",
        submitTime: ""
      },
      steelGradeList: [],
      steelTypes: [],
      /* 设置总记录数 */
      total: 0,
      /* 设置分页数据 */
      tableData: [],
      customerList: []
    };
  },
  mounted() {
    this.getReviewedOrder();
    this.getSteelGradeName();
    this.getsteelTypeNames();
    this.getCustomerNames();
  },
  methods: {
    formatterTime(time) {
      if (time !== "" && time !== undefined) {
        return timeChange(time);
      } else {
        return "";
      }
    },
    getReviewedOrder() {
      post(GET_STANDARD_OPINIONRECORD, this.queryForm).then(resp => {
        const { total, rows } = resp;
        this.total = total;
        this.tableData = rows;
      });
    },
    handleReset() {
      this.$refs["queryForm"].resetFields();
    },
    handleCurrentChange(current) {
      this.queryForm.current = current;
      this.getReviewedOrder();
    },
    handleSizeChange(page) {
      this.queryForm.page = page;
      this.handleCurrentChange(1);
    },
    handleViewContent(row) {
      this.$router.push({
        path: "/standard/orderRecordInfo",
        query: { id: row.id }
      });
    },
    getSteelGradeName() {
      post(GET_STEELGRADELIST, { steelGradeName: "" }).then(resp => {
        this.steelGradeList = resp.data;
      });
    },
    // 获取顾客
    getCustomerNames() {
      post(GET_CUSTOMERNAMELIST, { customerName: "" }).then(resp => {
        this.customerList = resp.data;
      });
    },
    // 获取钢类
    getsteelTypeNames() {
      post(GET_STEELTYPELIST, { steelTypeName: "" }).then(resp => {
        this.steelTypes = resp.data;
      });
    }
  }
};
</script>

<style scoped>
</style>
